package com.kksoft.readcm.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.kksoft.readcm.activity.App;
import com.kksoft.readcm.objects.k;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;

public final class SqliteAppObservable extends AppObservable     //old x
{
  private AtomicBoolean k;
  private ak l;
  private SQLiteDatabase m;
  private final Context n;

  public SqliteAppObservable()
  {
    AtomicBoolean localAtomicBoolean = new AtomicBoolean();
    this.k = localAtomicBoolean;
    Context localContext = App.getAppThis();
    this.n = localContext;
  }

  public final SqliteAppObservable a()
  {
    if ((!this.k.get()) && (!this.a))
      this.k.set(true);
    while (true)
    {
      try
      {
        Context localContext = this.n;
        ak localak = new ak(localContext);
        this.l = localak;
        SQLiteDatabase localSQLiteDatabase = this.l.getWritableDatabase();
        this.m = localSQLiteDatabase;
        SqliteAppObservable localx = this;
        return localx;
      }
      catch (SQLException localSQLException)
      {
        App.showError(localSQLException);
        continue;
      }
      //x localx = null;
    }
  }

  public final boolean a(ArrayList paramArrayList)
  {
    int i;
    if ((!this.k.get()) || (this.a))
      i = 0;
    while (true)
    {
      return false;
//      com.kksoft.readcm.objects.l.R();
//      try
//      {
//        this.m.beginTransaction();
//        localIterator = paramArrayList.iterator();
//        while (true)
//        {
//          if (!localIterator.hasNext())
//          {
//            this.m.setTransactionSuccessful();
//            this.m.endTransaction();
//            localIterator = paramArrayList.iterator();
//            if (localIterator.hasNext())
//              break label159;
//            s locals = this.d;
//            App.a(new l(locals));
//            i = 1;
//            break;
//          }
//          k localk = (k)localIterator.next();
//          if (localk.d())
//            continue;
//          SQLiteDatabase localSQLiteDatabase = this.m;
//          String str = localk.a();
//          String[] arrayOfString = localk.b();
//          localSQLiteDatabase.execSQL(str, arrayOfString);
//        }
//      }
//      catch (SQLException localSQLException)
//      {
//        while (true)
//        {
//          Iterator localIterator;
//          a(localSQLException);
//          int j = 0;
//          break;
//          ((k)localIterator.next()).c();
//        }
//      }
//      catch (IllegalStateException localIllegalStateException)
//      {
//        while (true)
//          label159: a(localIllegalStateException);
//      }
    }
  }

  public final void b()
  {
//    if (this.k.getAndSet(0))
//      this.l.close();
  }

  public final void c()
  {
    boolean bool = this.n.deleteDatabase("ril");
  }

  public final boolean d()
  {
    return this.k.get();
  }

  public final Cursor e()
  {
    String str1;
    switch (App.getSharedPreferences().getInt("sortReading", 1))
    {
    default:
      str1 = "time_added DESC";
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      SQLiteDatabase localSQLiteDatabase = this.m;
      String[] arrayOfString1 = new String[19];
      arrayOfString1[0] = "item_id";
      arrayOfString1[1] = "unique_id";
      arrayOfString1[2] = "given_url";
      arrayOfString1[3] = "given_normal_url";
      arrayOfString1[4] = "resolved_url";
      arrayOfString1[5] = "resolved_normal_url";
      arrayOfString1[6] = "title";
      arrayOfString1[7] = "time_added";
      arrayOfString1[8] = "offline_web";
      arrayOfString1[9] = "offline_text";
      arrayOfString1[10] = "is_not_article";
      arrayOfString1[11] = "percent";
      arrayOfString1[12] = "encoding";
      arrayOfString1[13] = "mime";
      arrayOfString1[14] = "domain";
      arrayOfString1[15] = "resolved_title";
      arrayOfString1[16] = "excerpt";
      arrayOfString1[17] = "image";
      arrayOfString1[18] = "video";
      String[] arrayOfString2 = null;
      String str2 = null;
      String str3 = null;
//      return localSQLiteDatabase.query("items", arrayOfString1, null, arrayOfString2, str2, str3, str1);
//      str1 = "time_added ASC";
      continue;
//      str1 = "title ASC";
//      continue;
//      str1 = "given_url ASC";
    }
  }

  public final Cursor f()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[3];
    arrayOfString1[0] = "rowid";
    arrayOfString1[1] = "type";
    arrayOfString1[2] = "url";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    String str3 = null;
    return localSQLiteDatabase.query("sync_queue", arrayOfString1, null, arrayOfString2, str1, str2, str3);
  }

  public final Cursor g()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[1];
    arrayOfString1[0] = "host";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    String str3 = null;
    return localSQLiteDatabase.query("failed_hosts", arrayOfString1, null, arrayOfString2, str1, str2, str3);
  }

  public final Cursor h()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[7];
    arrayOfString1[0] = "item_id";
    arrayOfString1[1] = "view";
    arrayOfString1[2] = "section";
    arrayOfString1[3] = "page";
    arrayOfString1[4] = "node_index";
    arrayOfString1[5] = "percent";
    arrayOfString1[6] = "time_updated";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    return localSQLiteDatabase.query("scroll", arrayOfString1, null, arrayOfString2, str1, str2, "time_updated");
  }

  public final void i()
  {
    super.i();
    b();
    c();
  }

  public final Cursor j()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[2];
    arrayOfString1[0] = "item_id";
    arrayOfString1[1] = "tag";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    String str3 = null;
    return localSQLiteDatabase.query("tags", arrayOfString1, null, arrayOfString2, str1, str2, str3);
  }

  public final Cursor k()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[5];
    arrayOfString1[0] = "item_id";
    arrayOfString1[1] = "image_id";
    arrayOfString1[2] = "src";
    arrayOfString1[3] = "caption";
    arrayOfString1[4] = "credit";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    return localSQLiteDatabase.query("items_images", arrayOfString1, null, arrayOfString2, str1, str2, "image_id");
  }

  public final Cursor l()
  {
    SQLiteDatabase localSQLiteDatabase = this.m;
    String[] arrayOfString1 = new String[5];
    arrayOfString1[0] = "item_id";
    arrayOfString1[1] = "video_id";
    arrayOfString1[2] = "src";
    arrayOfString1[3] = "type";
    arrayOfString1[4] = "vid";
    String[] arrayOfString2 = null;
    String str1 = null;
    String str2 = null;
    return localSQLiteDatabase.query("items_videos", arrayOfString1, null, arrayOfString2, str1, str2, "video_id");
  }

  public final Cursor m()
  {
    return this.m.rawQuery("SELECT assets.asset_domain AS asset_domain, COUNT(assets_items.item_id) AS retain FROM assets LEFT OUTER JOIN assets_items ON assets.asset_domain = assets_items.asset_domain GROUP BY assets.asset_domain", null);
  }
}

/* Location:           E:\AndroidDecompiler\jd-gui-0.3.3.windows\newrclasses.dex.dex2jar.jar
 * Qualified Name:     com.kksoft.readcm.a.x
 * JD-Core Version:    0.6.0
 */